package com.teemor.open.openauth.validator;


import com.teemor.open.openauth.model.AuthResource;
import com.teemor.open.openauth.model.AuthUserModel;

/**
 * @ename zhoulk
 * @cname 周李科
 * @date 2020/6/2 15:38
 */
public class BaseRoleValidator implements RoleValidator<Boolean> {

    @Override
    public Boolean valid(AuthUserModel authUserModel, AuthResource authResource) {
//        String[] roles = authResource.getRoles().split(",");
        for (Integer role: authResource.getRoles()) {
            if (!authUserModel.getRoles().contains(role)) {
                return false;
            }
        }
        return true;
    }
}
